#ifndef	_ENTITY_H_ 
#define _ENTITY_H_

#include "Graphics.h"

namespace Cartesia {

class CARTESIA_API Entity {

public:
	float	_posX;
	float	_posY;
	float	_posZ;
	float	_width;
	float	_height;
	float	_angle;
	float	_scale;
	float	_scaleX;
	float	_scaleY;
	float	_pivotPosX;
	float	_pivotPosY;

	float	_previousPosX;
	float	_previousPosY;
	float	_previousAngle;

	bool	_visible;

	//-------------------------------------------------------------------

	// Setea la posicion
	virtual void Entity::SetPos(float x, float y)
	{
		_previousPosX = _posX;
		_previousPosY = _posY;
		_posX = x;
		_posY = y;
		_pivotPosX = 0.0f;
		_pivotPosY = 0.0f;
	}

	//-------------------------------------------------------------------

	// Setea la posicion
	virtual void Entity::SetPivot(float u, float v)
	{
		_pivotPosX = (u * _width) ;// * -1;
		_pivotPosY = (v * _height);// * -1;
	}

	//-------------------------------------------------------------------

	// Setea la escala
	void Entity::SetScale(float scaleX, float scaleY)
	{
		_scaleX = scaleX;
		_scaleY = scaleY;
	}

	//-------------------------------------------------------------------

	// Setea la rotacion en grados
	void Entity::SetRotation(float angle)
	{
		_angle = D3DXToRadian(angle);
	}
	
	//-------------------------------------------------------------------

	// Setea la dimension (ancho y alto)
	virtual void Entity::SetDim(float width, float height)
	{
		_width  = width;
		_height = height;
	}

	//-------------------------------------------------------------------

	// Dibujado
	virtual void Draw()
	{
		if (_visible)
		{
			Graphics::LoadIdentity();
			Graphics::Translate(_posX, _posY, 1.0f);
			Graphics::RotateZ(_angle);
			Graphics::Translate(_pivotPosX, _pivotPosY, 1.0f);
		}
	}


	//-------------------------------------------------------------------

	Entity::Entity()
	{
		_posX	= 0.0f;
		_posY	= 0.0f;
		_posZ	= 0.0f;
		_width	= 0.0f;
		_height	= 0.0f;
		_angle	= 0.0f;
		_scale	= 1.0f;
		_scaleX	= _scale;
		_scaleY	= _scale;
		_pivotPosX	= 0.0f;
		_pivotPosY	= 0.0f;
		_visible	= true;
	}

	Entity::~Entity(){}
};


} // end namespace

#endif //_ENTITY_H_